import { UserProfiles } from "@/request/api"
export default {
    namespaced: true,
    state: {
        userInfo: {
            nickName: "略略略",
            headImg: require("../../assets/img/bb1.png"),
            coin: 0

        },
        cartTotal: 8
    },
    mutations: {
        changeIuserInfo(state, payload) {
            state.userInfo = payload.userInfo
            state.cartTotal = payload.cartTotal
        },
        //初始化仓库
        initUserInfo(state) {
            state.userInfo = {
                nickName: "略略略",
                headImg: require("../../assets/img/bb1.png"),
                coin: 0
            },
                state.cartTotal = 8
        }
    },
    actions: {
        async asyncchangeIuserInfo({ commit }) {
            let user = await UserProfiles();
            console.log("用户信息", user);
            commit("changeIuserInfo", user.data)
        }
    }

}